package com.edu.control.deploy;

import com.edu.control.OpenFaasGatewayImpl;
import com.edu.control.model.DeployRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DeployTask implements Runnable {

    private static final Logger LOGGER = LoggerFactory.getLogger(DeployTask.class);

    private DeployRequest deployRequest;

    private OpenFaasGatewayImpl openFaasGatewayImpl;

    public DeployTask(DeployRequest deployRequest, OpenFaasGatewayImpl openFaasGatewayImpl) {
        this.deployRequest = deployRequest;
        this.openFaasGatewayImpl = openFaasGatewayImpl;
    }

    @Override
    public void run() {
        try {
            openFaasGatewayImpl.deployFunction(deployRequest);
        } catch (Exception e) {
            LOGGER.error("deploy task interrupt {}", e.getMessage());
        }
    }
}
